<template>
	<view>
		<view class="windowclasstype">
			<view class="windowclass">
				<view class="bind_top">
					<view class="bind_top_img">
						<image class="bind_top_img" src="../../static/logo.png"></image>
					</view>
				</view>
				<!-- 用户 -->
				<view class="bind_user">
					<view class="bind_user_left">{{icons.shoujinhao}}
						<view class="bind_user_left_width"></view>
					</view>
					<view class="bind_user_moddle">
						<input id="querydate" @input="user_input" @focus="user_focus" @blur="user_blur" placeholder="请输入手机号/邮箱"
							maxlength="50" type="text" v-model="user_value" class="bind_user_moddle_input" />
					</view>
					<view v-if="phonedata!=''" :class="starts==true?'bind_user_right2':'bind_user_right'"
						@tap="kan_user">{{starts==true?icons.xiasanjiao:icons.shangsanjiao}}</view>
					<view v-else :class="starts==true?'bind_user_right2':'bind_user_right'"></view>
					<view class="user_action" v-if="starts">
						<uni-swipe-action v-if="starts">
							<uni-swipe-action-item v-for="(phonevalue,index) in phonedata" :key="phonevalue.phone"
								:class="index==0?'cont_m':'cont'" :options="phonevalue.options" @click="onClick"
								@change="change">
								<view class="conts" @tap="phonevalue_on(index)">
									<view class="cont_left">{{phonevalue.phone}}</view>
									<view class="cont_right">
										<image :src="phonevalue.img" class="cont_right_img"></image>
									</view>
								</view>
							</uni-swipe-action-item>
						</uni-swipe-action>
					</view>
				</view>
				<!-- 密码 -->
				<view v-if="num_fan!=123" class="bind_pwd">
					<view class="bind_user_left">{{icons.mima}}
						<view class="bind_user_left_width"></view>
					</view>
					<view class="bind_user_moddle">
						<input @input="pwd_input" :placeholder="ma_name" type="text" :password="pwd_type"
							v-model="pwd_value" class="bind_user_moddle_input" />
					</view>
					<view :class="kanpwd_type==false?'bind_user_right':'bind_user_right2'" @tap="kan_pwd">
						{{kanpwd_type==false?icons.guangbimima:icons.xianshimima}}
					</view>
				</view>
				<!-- 验证码 -->
				<!-- <view v-if="thevalue_type==true && num_fan!=123" class="bind_val">
					<view class="bind_val_left">
						<input type="number" v-model="val_value" class="bind_val_left_input" maxlength="4"
							placeholder="请输入验证码" />
					</view>
					<view class="bind_val_right" @tap="getrandomnum">{{thevalue}}</view>
				</view> -->
				<!-- 登录 -->
				<view class="bind_submit" @tap="submit">{{den_name}}</view>
				<!-- 忘记密码，记住密码 -->
				<view class="bind_botton">
					<view class="bind_botton_left">
						<view class="bind_botton_left_left">
							<view class="bind_botton_botton" @tap="bottom_onoff"
								:style="{background:botton_off==false?'':icon.color}">
								<view class="bind_botton_botton_off" :style="{left:botton_off==false?'0px':'40rpx'}">
								</view>
							</view>
						</view>
						<view class="bind_botton_left_right">记住账号密码</view>
					</view>
					<view class="bind_botton_right" @tap="xiu_pwd">忘记密码</view>
				</view>
				<!-- 授权 -->
				<div class="other" @tap="open">其他方式登录</div>
				<!-- <div v-if="apple" class="otherapple" @tap="openapple">{{icons.apple+' '}}通过Apple登录</div> -->
				<div class="othoervalue">
					<div v-if="othervalue.name!='apple'" @tap="otherlogin(othervalue.eng)"
						:style="{color:othervalue.color,fontSize:othervalue.size+'rpx'}" class="othericons"
						v-for="(othervalue,otherindex) in otherdata" :key="otherindex">{{othervalue.icon}}</div>
					<div v-if="apple" @tap="openapple" :style="{color:'#000',fontSize:'40rpx'}" class="othericons">
						{{icons.apple}}
					</div>

				</div>
				<!-- <uni-popup  :animation="animationpopup" type="bottom" ref="otherpopup">
			<view class="otherpopup">
				<div @tap="otherlogin(othervalue.eng)" class="otherpopup_all" v-for="othervalue in otherdata" :key="othervalue.eng">
					<view class="otherpopup_icon" v-html="othervalue.icon" :style="{color:othervalue.color}"></view>
					<view class="otherpopup_name">{{othervalue.name}}</view>
				</div>
			</view>
		</uni-popup> -->
				<!-- 登录弹出 -->
				<message :bindwidth="width" :bindheight="height" :bindstart="otherstart" :bindphone="user_value"
					:bindtype="bindtype" :wxname="wxname" :wxhead="wxhead" :wxnum="wxnum"></message>
			</view>
		</view>
	</view>
</template>

<script>
	var curCount;
	var _self;
	var phonecheck = /^1(3|4|5|7|8|9)\d{9}$/;
	var randomcheck = /^[0-9]{4}$/;
	var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
	var reg1 = /^[\S]{6,15}$/;
	var reg2 = /[\_\/\-\*\+\?\>\<\"\'\{\}\[\]\_\=\!\@\#\$\%\^\&\*\(\)\.\,\|\\\:\`\~]/;
	var reg3 = /\d/;
	var reg5 = /^[0-9]*$/;
	var reg4 = /[\a-zA-Z]/;
	var IntervalObj;
	import message from "../components/myuni-message/myuni-message.vue";
	import md5 from "../common/md5.js";
	export default {
		components: {
			message
		},
		data() {
			return {
				apple: false,
				animationpopup: true,
				styles: { //动画属性配置
					'width': '100%',
					'height': '100%',
					'backgroundColor': 'blue',
					'margin': 'auto',

				},
				icon: '',
				icons: '',
				dentype: 'phone', //登录类型
				user_value: '', //账号
				pwd_value: '', //密码
				val_value: '', //验证码
				pwd_type: true, //是否显示密码
				kanpwd_type: false, //是否显示密码
				starts: false, //开启历史账号
				bindtype: '',
				phonedata: [ //账号历史记录
					{
						phone: 13536443013,
						pwd: '',
						img: '../../static/HM-PersonalCenter/sever/baox.png',
						options: [{
							id: 13536443013,
							text: '删除',
							style: {
								backgroundColor: '#dd524d',
								fontSize: '20px'
							}
						}]

					},
					{
						phone: 12345678910,
						pwd: '',
						img: '../../static/HM-PersonalCenter/sever/baox.png',
						options: [{
							id: 12345678910,
							text: '删除',
							style: {
								backgroundColor: '#dd524d',
								fontSize: '20px'
							}
						}]
					},
					{
						phone: 123456789,
						pwd: '',
						img: '../../static/HM-PersonalCenter/sever/baox.png',
						options: [{
							id: 123456789,
							text: '删除',
							style: {
								backgroundColor: '#dd524d',
								fontSize: '20px'
							}
						}]
					}
				],
				botton_off: false, //是否记住密码
				state: true, //是否可以获取验证码
				thevalue: '获取验证码', //验证码显示文字
				ma_name: '请输入密码', //密码提示
				den_name: '登录/注册', //登录按钮文字
				num_fan: 123, //返回判断是否注册
				thevalue_type: false,
				fan_yzm: '', //返回加密验证码
				title: '登录', //标题
				otherdata: [ //登录方式
					{
						name: '短信登录',
						icon: '',
						color: '#0af',
						size: 40,
						eng: 'dx'
					},
					{
						name: '邮箱验证登录',
						icon: '',
						color: '#ea9518',
						size: 40,
						eng: 'yx'
					},
					{
						name: '微信登录',
						icon: '',
						color: '#5bc402',
						size: 40,
						eng: 'wx'
					},
					{
						name: 'apple',
						icon: '',
						color: '#000',
						size: 40,
						eng: 'apple'
					}
				],
				otherstart: false,
				wxname: '',
				wxhead: '',
				wxnum: '',
				width: '', //屏幕宽度（单位px）
				height: '', //屏幕显示高度（单位px）

			}
		},
		onBackPress(options) {
			console.log(options);
			if ((options.from === 'backbutton' || options.from === 'navigateBack') && this.otherstart == false) {
				return false;
			}
			uni.setNavigationBarTitle({
				title: '登录'
			});
			_self.title = '登录';
			this.otherstart = false;
			return true;
		},
		onShow() {

		},
		onReady() {
			uni.createSelectorQuery() /* 获取查询节点 */
				.selectAll('.windowclass') /* 获取class(.lazy) */
				.boundingClientRect(images => {
					/*  console.log(images);console.log(uni.getSystemInfoSync().windowHeight+"h"); */
					var arr = [];
					images.forEach((image, index) => {
						_self.width = image.width;
						_self.height = image.height;

					});

				})
				.exec();
			//#ifdef APP-PLUS
			try {
				const res = uni.getSystemInfoSync();
				if (res.platform == 'ios' && parseInt(res.system.split(' ')[1]) > 12) {
					this.apple = true;
				}
			} catch (e) {
				console.log(e);
				// error
			}
			//#endif
		},
		onLoad() {
			_self = this;
			this.icon = uni.getStorageSync('icon');
			this.icons = uni.getStorageSync('icons');
			this.otherdata[0].icon = this.icons.duanxinden;
			this.otherdata[1].icon = this.icons.youxiangden;
			this.otherdata[2].icon = this.icons.weixinfenxiang;
			this.otherdata[3].icon = this.icons.apple;
			this.phonedata = uni.getStorageSync('zhanpass');
			console.log(this.num_fan);

		},
		methods: {
			wxdeng: function() {
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						uni.showLoading({
							title: '正在获取信息...',
							mask: true,
						});
						uni.getUserInfo({
							provider: 'weixin',
							success: function(infoRes) {
								_self.wxname = infoRes.userInfo.nickName;
								_self.wxhead = infoRes.userInfo.avatarUrl;
								_self.wxnum = infoRes.userInfo.unionId;
								uni.request({
									url: uni.getStorageSync('APP_key') + '/denwx.php',
									method: 'POST',
									data: {
										user: '04d553e4316ffcdb1a2ab1efffbdd07e',
										appid: infoRes.userInfo.unionId
									},
									header: {
										'content-type': 'application/x-www-form-urlencoded'
									},
									dataType: 'json',
									success: function(res) {
										console.log(res);
										setTimeout(function() {
											uni.hideLoading();
										}, 300);
										console.log(infoRes);
										if (res.data.user != null) {
											uni.setStorageSync('user', res.data
												.user); //登陆凭证
											uni.setStorageSync('user_key', res.data
												.user_key);
											uni.setStorageSync('yhpz', res.data
												.yhpz);
											getApp().datalist();
											uni.navigateBack({
												delta: 1
											});
										} else {
											_self.otherstart = true;
											uni.setNavigationBarTitle({
												title: '验证手机或邮箱'
											});
											_self.title = '验证手机或邮箱';
										}
									}
								});
							}
						});
					}
				});
			},
			otherchange: function(e) {
				console.log(e)
			},
			otherlogin: function(e) {
				this.bindtype = e;
				if (e === 'wx') { //微信登录
					this.wxdeng();

				} else if (e === 'dx') { //短信登录

					this.otherstart = true;
					uni.setNavigationBarTitle({
						title: '手机短信登录'
					});
					this.title = '手机短信登录';
				} else if (e === 'yx') { //短信登录

					this.otherstart = true;
					uni.setNavigationBarTitle({
						title: '邮箱验证登录'
					});
					this.title = '邮箱验证登录';
				}
			},
			openapple: function() { //苹果登录

				this.bindtype = 'apple';
				uni.login({
					provider: 'apple',
					success: function(loginRes) {
						// 登录成功  
						uni.getUserInfo({
							provider: 'apple',
							success: (res) => {
								console.log(res);
								_self.wxnum = res.userInfo.openId;
								// 获取用户信息成功  
								uni.request({
									url: uni.getStorageSync('APP_key') +
										'/denapple.php',
									method: 'POST',
									data: {
										user: '04d553e4316ffcdb1a2ab1efffbdd07e',
										appid: res.userInfo.openId,
									},
									header: {
										'content-type': 'application/x-www-form-urlencoded'
									},
									dataType: 'json',
									success: function(res) {
										console.log(res);
										setTimeout(function() {
											uni.hideLoading();
										}, 300);

										if (res.data.user != null) {
											uni.setStorageSync('user', res.data
												.user); //登陆凭证
											uni.setStorageSync('user_key', res.data
												.user_key);
											uni.setStorageSync('yhpz', res.data
												.yhpz);
											getApp().datalist();
											uni.navigateBack({
												delta: 1
											});
										} else {
											_self.otherstart = true;
											uni.setNavigationBarTitle({
												title: '验证手机或邮箱'
											});
											_self.title = '验证手机或邮箱';
										}
									}
								});
							}
						})
					},
					fail: function(err) {
						console.log(err);
						// 登录失败  
					}
				});


			},
			open: function() { //打开其他方式登录 
			},

			tomine: function() {
				// 返回上一层
				if (this.otherstart == true) {
					this.otherstart = false;
					this.title = "登录";
				} else if (this.otherstart == false && this.title === '登录') {
					uni.navigateBack({
						delta: 1
					})
				}
			},
			xiu_pwd: function() { //修改密码
				uni.navigateTo({
					url: '../../pagesB/xiu_pwd/xiu_pwd?phone=' + this.user_value,
				})

			},
			user_focus: function() { //输入账号焦点
				this.starts = false;
			},
			phonevalue_on: function(id) { //点击历史账号登录

				this.user_value = this.phonedata[id].phone;
				this.pwd_value = this.phonedata[id].pwd;
				this.botton_off = true;
				var obj = {
					detail: {
						value: this.phonedata[id].phone
					}
				};
				this.user_blur_auto(obj);
				this.kan_user();

			},

			getrandomnum: function() { //获取验证码

				if (this.pwd_value == '') {
					if (this.num_fan == false) {
						uni.showToast({
							icon: 'none',
							title: '请输入设置密码',
							duration: 2000,
						});
					} else {
						uni.showToast({
							icon: 'none',
							title: '请输入密码',
							duration: 2000,
						});
					}

					return;
				}
				if (!reg1.test(this.pwd_value)) {
					uni.showToast({
						icon: 'none',
						title: '密码至少6位！',
						duration: 2000,
					});
					return;
				}
				if (this.state == true) {
					uni.showToast({
						icon: 'none',
						title: '正在发生验证码...',
						duration: 2000,
					});
					uni.request({
						url: uni.getStorageSync('APP_key') + '/huo_code_config.php',
						method: 'POST',
						data: {
							phone: this.user_value,
							id: 20,
							time: 10,
							muid: 270356,
							codetype: this.dentype
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
						},
						dataType: 'json',
						success: (res) => {
							setTimeout(function() {
								uni.showToast({
									icon: 'none',
									title: '验证码已发送',
									duration: 2000,
								});
							}, 2000);
							curCount = parseInt(res.data.time) + 600;
							this.fan_yzm = res.data.code;
							if (res.data.id == 456) {
								(parseInt(Date.parse(new Date())) / 1000)
								this.state = false;
								IntervalObj = setInterval(() => {
									if ((curCount - (parseInt(Date.parse(new Date())) / 1000)) <=
										0) { //超时重新获取验证码                
										clearInterval(IntervalObj); // 停止计时器
										this.state = true;
										this.thevalue = "重新获取";
									} else {
										console.log(curCount);
										this.thevalue = (curCount - (parseInt(Date.parse(
											new Date())) / 1000)) + "s";
									}
								}, 1000);
							}
						}
					});
				}
			},
			bottom_onoff: function() {
				this.botton_off = !this.botton_off;
			},
			onClick: function(e) {
				this.phonedata.forEach((item, id) => {
					if (e.content.id == item.phone) {
						this.phonedata.splice(id, 1);
					}
				});
				uni.setStorageSync('zhanpass', this.phonedata);
			},
			change: function(open) {
				console.log('当前开启状态：' + open)
			},
			kan_user: function() {
				this.starts = !this.starts;
			},
			userchange: function(e) {

			},
			user_input_yanzhen: function(e) {
				uni.getNetworkType({
					success: (res) => {
						if (res.networkType == 'none') {
							uni.showModal({
								title: '网络错误',
								content: '当前无网络,请检查设置您的网络！',
								showCancel: false,
								success: function(res) {
									if (res.confirm) {
										console.log('用户点击确定');
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});

						} else {
							uni.showLoading({
								title: '正在安全验证...',
								mask: true,
							});
							var acc_num = e;
							uni.request({
								url: 'https://adjyxw.h1668.com/home/index/register',
								method: 'POST',
								data: {
									mobile: acc_num,
									type: 'cha'
								},
								header: {
									"X-Requested-With": "XMLHttpRequest"
								},
								dataType: 'json',
								success: (res) => {
									setTimeout(function() {
										uni.hideLoading();
									}, 1000);
									setTimeout(function() {
										this.num_fan = res.data.data;
										if (res.data.data == false) {
											this.ma_name = '请设置登录密码';
											this.den_name = '注册';
											uni.showModal({
												title: '提示',
												content: '该手机号没有注册，请设置密码注册！',
												showCancel: false,
												success: function(res) {
													if (res.confirm) {
														console.log(
															'用户点击确定');
													} else if (res
														.cancel) {
														console.log(
															'用户点击取消');
													}
												}
											});

										} else if (res.data.data == true) {
											this.ma_name = '输入登录密码';
											this.den_name = '登录';
											/* uni.showModal({
											    title: '提示',
											    content: '该手机号已注册，请输入密码登录！',
												showCancel:false,
											    success: function (res) {
											        if (res.confirm) {
											            console.log('用户点击确定');
											        } else if (res.cancel) {
											            console.log('用户点击取消');
											        }
											    }
											}); */

										}
									}.bind(this), 1000);
								},
								fail: (res) => {
									this.user_input_yanzhen(e);
								}
							});
						}
					}
				});


			},
			user_input_yanzhen_auto: function(e) {
				uni.getNetworkType({
					success: (res) => {
						if (res.networkType == 'none') {
							uni.showModal({
								title: '网络错误',
								content: '当前无网络,请检查设置您的网络！',
								showCancel: false,
								success: function(res) {
									if (res.confirm) {
										console.log('用户点击确定');
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});

						} else {
							uni.showLoading({
								title: '正在安全验证...',
								mask: true,
							});
							var acc_num = e;
							uni.request({
								url: 'https://adjyxw.h1668.com/home/index/register',
								method: 'POST',
								data: {
									mobile: acc_num,
									password: this.pwd_value,
									type: 'cha'
								},
								header: {
									"X-Requested-With": "XMLHttpRequest"
								},
								dataType: 'json',
								success: (res) => {
									setTimeout(function() {
										uni.hideLoading();
									}, 1000);
									setTimeout(function() {
										this.num_fan = res.data.data;
										if (res.data.data == false) {
											this.ma_name = '请设置登录密码';
											this.den_name = '注册';
											uni.showModal({
												title: '提示',
												content: '该手机号没有注册，请设置密码注册！',
												showCancel: false,
												success: function(res) {
													if (res.confirm) {
														console.log(
															'用户点击确定');
													} else if (res
														.cancel) {
														console.log(
															'用户点击取消');
													}
												}
											});

										} else if (res.data.data == true) {
											this.ma_name = '输入登录密码';
											this.den_name = '登录';
											this.submit();
											/* uni.showModal({
											    title: '提示',
											    content: '该手机号已注册，请输入密码登录！',
												showCancel:false,
											    success: function (res) {
											        if (res.confirm) {
											            console.log('用户点击确定');
											        } else if (res.cancel) {
											            console.log('用户点击取消');
											        }
											    }
											}); */

										}
									}.bind(this), 1000);
								},
								fail: (res) => {
									this.user_input_yanzhen(e);
								}
							});
						}
					}
				});


			},
			user_input: function(e) {
				//this.pwd_type=false;
				this.thevalue_type = false;
				this.pwd_value = '', //密码
				this.val_value = '', //验证码
				this.den_name = '登录/注册';
				this.num_fan = 123;
			},
			user_blur_auto: function(e) {
				/* if(this.acc_num==''){
				         this.input_size=16;
				     }else{
				     this.input_size=20;  
				     } */
				if (String(e.detail.value) == '') {
					this.num_fan = 123;
					uni.showToast({
						icon: 'none',
						title: '手机号/邮箱不能为空',
						duration: 2000,
					});
					return;
				}
				if (!phonecheck.test(e.detail.value)) {

					if (!reg.test(e.detail.value)) {

						uni.showToast({
							icon: 'none',
							title: '手机号/邮箱错误',
							duration: 2000,
						});
						return;

					} else {
						this.dentype = 'email';
					}

				} else {
					this.dentype = 'phone';
				}

				this.user_input_yanzhen_auto(e.detail.value);
				/* this.den_name='登录/注册';
				       this.num_fan=123; */


			},
			user_blur: function(e) {
				/* if(this.acc_num==''){
				         this.input_size=16;
				     }else{
				     this.input_size=20;  
				     } */
				if (String(e.detail.value) == '') {
					this.num_fan = 123;
					uni.showToast({
						icon: 'none',
						title: '手机号/邮箱不能为空',
						duration: 2000,
					});
					return;
				}
				if (!phonecheck.test(e.detail.value)) {

					if (!reg.test(e.detail.value)) {

						uni.showToast({
							icon: 'none',
							title: '手机号/邮箱错误',
							duration: 2000,
						});
						return;

					} else {
						this.dentype = 'email';
					}

				} else {
					this.dentype = 'phone';
				}

				this.user_input_yanzhen(e.detail.value);
				/* this.den_name='登录/注册';
				       this.num_fan=123; */
			},
			pwd_input: function(e) {
				if (e.detail.value == '') {
					//this.pwd_type=false;
					this.thevalue_type = false;
				} else if (e.detail.value != '' && this.kanpwd_type == true) {
					//this.pwd_type=false;
					if (this.num_fan == false) {
						this.thevalue_type = true;
					}
				} else {
					//this.pwd_type=true;
					if (this.num_fan == false) {
						this.thevalue_type = true;
					}
				}
			},
			kan_pwd: function() {
				this.kanpwd_type = !this.kanpwd_type;
				this.pwd_type = !this.pwd_type;
			},
			submit: function() { //提交

				if (this.num_fan == 123) {
					this.user_blur({
						detail: {
							value: this.user_value
						}
					});
					return;
				}
				var cid = '';
				var token = '';
				//#ifdef APP-PLUS
				cid = plus.push.getClientInfo().clientid;
				token = plus.push.getClientInfo().token;
				//#endif
				if (this.num_fan == true) { //登录

					if (this.user_value == '') {
						uni.showToast({
							icon: 'none',
							title: '请输入手机号/邮箱',
							duration: 2000,
						});
						return;
					}
					if (!phonecheck.test(this.user_value)) {
						if (!reg.test(this.user_value)) {
							uni.showToast({
								icon: 'none',
								title: '手机号/邮箱错误',
								duration: 2000,
							});
							return;
						}
					}
					if (!reg.test(this.user_value)) {
						if (!phonecheck.test(this.user_value)) {
							uni.showToast({
								icon: 'none',
								title: '手机号/邮箱错误',
								duration: 2000,
							});
							return;
						}
					}
					if (this.pwd_value == '') {
						uni.showToast({
							icon: 'none',
							title: '请输入密码',
							duration: 2000,
						});
						return;
					} else if (!reg1.test(this.pwd_value)) {
						uni.showToast({
							icon: 'none',
							title: '密码至少4位！',
							duration: 2000,
						});
						return;
					}


					uni.showLoading({
						title: '登录中',
						mask: true,
					});
					let acc_num = this.user_value;
					/*let password=hex_md5(hex_md5(hex_md5(this.password+'588He5s6**(*?.')));*/
					let password = this.pwd_value;

					uni.request({
						url: 'https://adjyxw.h1668.com/home/index/login',
						method: 'POST',
						data: {
							mobile: acc_num,
							password: password,
						},
						header: {
							"X-Requested-With": "XMLHttpRequest"
						},
						dataType: 'json',
						success: (res) => {
							setTimeout(function() {
								uni.hideLoading();
							}, 800);
							if (res.data.code == 1) {//登录成功
								var objs = null;
								if (_self.botton_off == true) { //记住账号密码
									var zhan = uni.getStorageSync('zhanpass');
									var obj_arr = new Array();
									var obj = {
										phone: _self.user_value,
										pwd: _self.pwd_value,
										img: res.data.head,
										options: [{
											id: _self.user_value,
											text: '删除',
											style: {
												backgroundColor: '#dd524d',
												fontSize: '20px'
											}
										}]

									};
									obj_arr.unshift(obj);


									for (var i = 0; i < zhan.length; i++) {
										if (zhan[i].phone != _self.user_value) {
											objs = {
												phone: zhan[i].phone,
												pwd: zhan[i].pwd,
												img: zhan[i].img,
												options: [{
													id: zhan[i].phone,
													text: '删除',
													style: {
														backgroundColor: '#dd524d',
														fontSize: '20px'
													}
												}]

											};
											obj_arr.push(objs);
										}
									}
									uni.setStorageSync('zhanpass', obj_arr);
								} else { //不记住账号密码
									var zhan = uni.getStorageSync('zhanpass');
									var obj_arr = new Array();
									for (var i = 0; i < zhan.length; i++) {
										if (zhan[i].phone != _self.user_value) {
											objs = {
												phone: zhan[i].phone,
												pwd: zhan[i].pwd,
												img: zhan[i].img,
												options: [{
													id: zhan[i].phone,
													text: '删除',
													style: {
														backgroundColor: '#dd524d',
														fontSize: '20px'
													}
												}]

											};
											obj_arr.push(objs);
										}
									}
									uni.setStorageSync('zhanpass', obj_arr);
								}

								setTimeout(function() {
									uni.showToast({
										icon: 'none',
										title: '登录成功！',
										duration: 2000,
									});
								}, 1000);
								//console.log(res);
								uni.setStorageSync('userInfo', res.data.data); //登陆凭证
								getApp().datalist();
								setTimeout(function() {
									uni.navigateBack({
										delta: 1
									});
								}, 3000);
							} else { //登录失败
								setTimeout(function() {
									uni.showModal({
										title: '提示',
										content: '账号或密码错误！',
										showCancel: false,
										success: function(res) {
											if (res.confirm) {
												console.log('用户点击确定');
											} else if (res.cancel) {
												console.log('用户点击取消');
											}
										}
									});
								}, 1000);

							}

						}

					});
				} else { //注册登录
					uni.request({
						url: 'https://adjyxw.h1668.com/home/index/login',
						method: 'POST',
						data: {
							mobile: this.user_value,
							password: this.pwd_value,
							type: 'login'
						},
						header: {
							"X-Requested-With": "XMLHttpRequest"
						},
						dataType: 'json',
						success: (res) => {
							if (this.user_value == '') {
								uni.showToast({
									icon: 'none',
									title: '请输入手机号/邮箱',
									duration: 2000,
								});
								return;
							}
							if (!phonecheck.test(this.user_value)) {
								if (!reg.test(this.user_value)) {
									uni.showToast({
										icon: 'none',
										title: '手机号/邮箱错误',
										duration: 2000,
									});
									return;
								}
							}
							if (!reg.test(this.user_value)) {
								if (!phonecheck.test(this.user_value)) {
									uni.showToast({
										icon: 'none',
										title: '手机号/邮箱错误',
										duration: 2000,
									});
									return;
								}
							}
							if (this.pwd_value == '') {
								uni.showToast({
									icon: 'none',
									title: '请输入密码',
									duration: 2000,
								});
								return;
							}
							if (!reg1.test(this.pwd_value)) {
								uni.showToast({
									icon: 'none',
									title: '密码至少6位！',
									duration: 2000,
								});
								return;
							}

							// if (this.val_value == '') {
							// 	uni.showToast({
							// 		icon: 'none',
							// 		title: '请输入验证码',
							// 		duration: 2000,
							// 	});
							// 	return;
							// } else if (this.val_value.length != 4) {
							// 	uni.showToast({
							// 		icon: 'none',
							// 		title: '请输入4位数字验证码！',
							// 		duration: 2000,
							// 	});

							// 	return;
							// } else if (!reg5.test(this.val_value)) {
							// 	uni.showToast({
							// 		icon: 'none',
							// 		title: '请输入4位数字验证码！',
							// 		duration: 2000,
							// 	});

							// 	return;
							// } else if (res.data.codejie != this.fan_yzm) {
							// 	uni.showToast({
							// 		icon: 'none',
							// 		title: '验证码错误！',
							// 		duration: 2000,
							// 	});
							// 	return;
							// }
							uni.showLoading({
								title: '注册中',
								mask: true,
							});

							/* let password=hex_md5(hex_md5(hex_md5(this.password+'588He5s6**(*?.')));*/
							let password = md5.hex(this.pwd_value);

							uni.request({
								url: 'https://adjyxw.h1668.com/home/index/register',
								method: 'POST',
								data: {
									mobile: this.user_value,
									password: password,
									type: 'zhu',
								},
								header: {
									"X-Requested-With": "XMLHttpRequest"
								},
								dataType: 'json',
								success: (res) => {
									setTimeout(function() {
										uni.hideLoading();
									}, 800);
									if (res.data.data == true) {
										var objs = null;
										if (_self.botton_off == true) {
											var zhan = uni.getStorageSync('zhanpass');
											var obj_arr = new Array();
											var obj = {
												phone: _self.user_value,
												pwd: _self.pwd_value,
												img: res.data.head,
												options: [{
													id: _self.user_value,
													text: '删除',
													style: {
														backgroundColor: '#dd524d',
														fontSize: '20px'
													}
												}]

											};
											obj_arr.unshift(obj);


											for (var i = 0; i < zhan.length; i++) {
												if (zhan[i].phone != _self.user_value) {
													objs = {
														phone: zhan[i].phone,
														pwd: zhan[i].pwd,
														img: zhan[i].img,
														options: [{
															id: zhan[i].phone,
															text: '删除',
															style: {
																backgroundColor: '#dd524d',
																fontSize: '20px'
															}
														}]

													};
													obj_arr.push(objs);
												}
											}
											uni.setStorageSync('zhanpass', obj_arr);
										} else {
											var zhan = uni.getStorageSync('zhanpass');
											var obj_arr = new Array();
											for (var i = 0; i < zhan.length; i++) {
												if (zhan[i].phone != _self.user_value) {
													objs = {
														phone: zhan[i].phone,
														pwd: zhan[i].pwd,
														img: zhan[i].img,
														options: [{
															id: zhan[i].phone,
															text: '删除',
															style: {
																backgroundColor: '#dd524d',
																fontSize: '20px'
															}
														}]

													};
													obj_arr.push(objs);
												}
											}
											uni.setStorageSync('zhanpass', obj_arr);
										}
										// uni.setStorageSync('user', res.data.user); //登陆凭证
										// uni.setStorageSync('user_key', res.data.user_key);
										// uni.setStorageSync('yhpz', res.data.yhpz);
										getApp().datalist();
										setTimeout(function() {
											uni.showToast({
												icon: 'none',
												title: '注册成功！请重新登录',
												duration: 2000,
											});
										}, 1000);
										setTimeout(() => {
											this.user_value = null,
											this.pwd_value = null
										},1000)
									} else {


									}

								}

							});
						}
					});
				}
			},
		}
	}
</script>

<style lang="scss">
	.windowclasstype {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 100vh;

		.windowclass {
			width: 100%;
			margin: auto;

			.otherapple {
				width: 130pt;
				height: 30pt;
				border-radius: 6pt;
				bottom: 0upx;
				text-align: center;
				line-height: 30pt;
				left: 0upx;
				margin: 60upx auto 0upx auto;
				font-size: $color-size-3;
				color: $color-black-0;
				border: 1upx solid $color-black-0;
				background-color: $bgcolor-white-0;
				font-family: iconfont;
			}

			.othoervalue {
				width: 100%;
				height: 80upx;
				display: flex;
				justify-content: center;
				align-items: center;

				.othericons {
					line-height: 60rpx;
					height: 60rpx;
					width: 60rpx;
					margin: 12rpx;
					text-align: center;
					text-align: center;
					font-family: iconfont;
					font-size: $color-sizeicon-14;
					background-color: $bgcolor-white-0;
					border: 2rpx solid $color-black-8;
					border-radius: 60rpx;
				}
			}

			.other {
				width: 100%;
				bottom: 0upx;
				text-align: center;
				line-height: 50upx;
				height: 50upx;
				left: 0upx;
				font-size: $color-size-2;
				color: $color-black-5;
			}

			.bind_top {
				margin: 0upx auto 40upx auto;
				width: 180upx;
				height: 180upx;
				border-radius: 180upx;
				overflow: hidden;

				.bind_top_img {
					width: 100%;
					height: 180upx;
					border-radius: 180upx;

				}
			}

			.bind_user {
				position: relative;
				z-index: 23;
				border-radius: 10upx;
				border: 1px solid $bkcolor-black-8;
				width: 80%;
				height: 80upx;
				background: $bgcolor-white-0;
				display: flex;
				justify-content: center;
				margin: 20upx auto;

				.bind_user_left {
					width: 100upx;
					height: 80upx;
					font-size: $color-sizeicon-10;
					text-align: center;
					font-family: iconfont;
					line-height: 80upx;
					color: $color-black-2;
					position: relative;

					.bind_user_left_width {
						width: 1px;
						height: 60upx;
						position: absolute;
						right: 0upx;
						top: 10upx;
						background: $bgcolor-black-7;
					}
				}

				.bind_user_moddle {
					height: 80upx;
					width: 96%;
					padding: 0upx 3%;

					.bind_user_moddle_input {
						width: 100%;
						height: 100%;
						font-size: $color-size-5;
					}
				}

				.bind_user_right {
					width: 100upx;
					height: 80upx;
					text-align: center;
					font-size: $color-sizeicon-3;
					font-family: iconfont;
					color: $color-black-2;
					line-height: 80upx;

				}

				.bind_user_right2 {
					width: 100upx;
					height: 80upx;
					text-align: center;
					font-size: $color-sizeicon-3;
					font-family: iconfont;
					color: $color-all;
					line-height: 80upx;
				}


			}

			.bind_pwd {
				position: relative;
				z-index: 20;
				border-radius: 10upx;
				border: 1px solid $bkcolor-black-8;
				width: 80%;
				height: 80upx;
				background: $bgcolor-white-0;
				display: flex;
				justify-content: center;
				margin: 20upx auto;

				.bind_user_left {
					width: 100upx;
					height: 80upx;
					font-size: $color-sizeicon-10;
					text-align: center;
					font-family: iconfont;
					line-height: 80upx;
					color: $color-black-2;
					position: relative;

					.bind_user_left_width {
						width: 1px;
						height: 60upx;
						position: absolute;
						right: 0upx;
						top: 10upx;
						background: $bgcolor-black-7;
					}
				}

				.bind_user_moddle {
					height: 80upx;
					width: 96%;
					padding: 0upx 3%;

					.bind_user_moddle_input {
						width: 100%;
						height: 100%;
						font-size: $color-size-5;
					}
				}

				.bind_user_right {
					width: 100upx;
					height: 80upx;
					text-align: center;
					font-size: $color-sizeicon-3;
					font-family: iconfont;
					color: $color-black-2;
					line-height: 80upx;

				}

				.bind_user_right2 {
					width: 100upx;
					height: 80upx;
					text-align: center;
					font-size: $color-sizeicon-3;
					font-family: iconfont;
					color: $color-all;
					line-height: 80upx;
				}


			}

			.bind_submit {
				width: 80%;
				height: 100upx;
				line-height: 100upx;
				font-size: $color-size-9;
				text-align: center;
				color: $color-white-0;
				background: $color-all;
				border-radius: 10upx;
				margin: 30upx auto 0upx auto;
				border-left: 1px solid $color-all;
				border-right: 1px solid $color-all;
			}

			.user_action {
				width: 100%;
				position: absolute;
				top: 86upx;
				left: 0upx;
				z-index: 9;
				border-radius: 10upx;
				display: inline-block;

				.cont {
					width: 600upx;
					height: 80upx;
					line-height: 80upx;
					z-index: 10;
					display: flex;
					justify-content: space-between;
					border-top: 1px solid $bkcolor-black-8;
				}

				.cont_m {
					width: 600upx;
					height: 80upx;
					line-height: 80upx;
					z-index: 10;
					display: flex;
					justify-content: space-between;
					border-top: 1px solid rgba($color: $bkcolor-black-8, $alpha: 0);
				}

				.conts {
					width: 600upx;
					height: 80upx;
					line-height: 80upx;
					z-index: 10;
					display: flex;
					justify-content: space-between;

					.cont_left {
						width: 400upx;
						height: 80upx;
						line-height: 80upx;
						font-size: $color-size-5;
						color: $color-all;
						padding-left: 10upx;
					}

					.cont_right {
						width: 60upx;
						height: 60upx;
						font-size: $color-size-5;
						color: $color-black-3;
						margin-top: 10upx;
						margin-right: 10upx;
						border-radius: 100upx;
						overflow: hidden;

						.cont_right_img {
							width: 100%;
							height: 100%;
						}
					}
				}
			}

			.bind_botton {
				width: 70%;
				height: 80upx;
				margin: 20upx auto;
				display: flex;
				justify-content: space-between;

				.bind_botton_left {
					width: 65%;
					height: 80upx;
					display: flex;
					justify-content: space-between;

					.bind_botton_left_left {
						width: 80upx;
						height: 60upx;
						line-height: 60upx;
						margin: 20upx 0upx;

						.bind_botton_botton {
							width: 80upx;
							height: 40upx;
							border-radius: 120upx;
							background: $bgcolor-white-0;
							border: 1px solid $bkcolor-black-8;
							position: relative;

							.bind_botton_botton_off {
								width: 40upx;
								height: 40upx;
								border-radius: 40upx;
								background-color: $bgcolor-white-0;
								position: absolute;
								top: 0upx;
								transition: left 0.5s;

								-webkit-transition: left 0.5s;
								/* Safari */
								-moz-transition: left 0.5s;
								filter: progid:DXImageTransform.Microsoft.Shadow(color=$color-black-8, Direction=135, Strength=5);
								/*for ie6,7,8*/
								-moz-box-shadow: 2px 2px 5px $color-black-8;
								/*firefox*/
								-webkit-box-shadow: 2px 2px 5px $color-black-8;
								/*webkit*/
								box-shadow: 2px 2px 5px $color-black-8;
								/*opera或ie9*/
							}
						}
					}

					.bind_botton_left_right {
						width: 80%;
						padding-left: 10upx;
						height: 80upx;
						line-height: 80upx;
						text-align: left;
						font-size: $color-size-3;
						color: $color-black-3;
					}
				}

				.bind_botton_right {
					width: 35%;
					height: 80upx;
					line-height: 80upx;
					text-align: right;
					font-size: $color-size-3;
					color: $color-black-3;
				}
			}

			.bind_val {
				width: 80%;
				margin: 20upx auto;
				height: 80upx;
				display: flex;
				justify-content: space-between;

				.bind_val_left {
					width: 45%;
					padding: 0upx 20upx;
					height: 78upx;
					border: 1px solid $bkcolor-black-8;
					background: $bgcolor-white-0;
					line-height: 78upx;
					border-radius: 10upx;

					.bind_val_left_input {
						width: 100%;
						height: 100%;
						font-size: $color-size-5;
					}
				}

				.bind_val_right {
					width: 35%;
					height: 80upx;
					background-color: rgba($color: $color-all, $alpha: 0.5);
					line-height: 80upx;
					text-align: center;
					font-size: $color-size-4;
					color: $color-white-0;
					border-radius: 10upx;
				}
			}


			.head {
				z-index: 50;
				position: fixed;
				top: 0;
				width: 100%;
				height: 100upx;
				background: #fff;
				padding-top: 50upx;

				.myadd {
					position: relative;
					width: 100%;
					height: 100upx;
					text-align: center;
					line-height: 100upx;
					font-size: $color-size-7;

					.myadd_icon {
						width: 100upx;
						height: 100upx;
						position: absolute;
						text-align: center;
						line-height: 100upx;
						left: 0upx;
						top: 0upx;
						font-size: $color-size-15;
						font-family: iconfont;
					}
				}
			}

			.otherpopup {
				width: 100%;
				height: 200upx;
				background-color: $bgcolor-white-0;
				display: flex;
				justify-content: center;

				.otherpopup_all {
					height: 180upx;
					width: 50%;
					margin: 10upx 0upx;

					.otherpopup_icon {
						width: 100%;
						line-height: 150upx;
						height: 150upx;
						font-size: 100upx;
						font-family: iconfont;
						text-align: center;
					}

					.otherpopup_name {
						width: 100%;
						height: 30upx;
						line-height: 10upx;
						text-align: center;
						font-size: $color-size-3;
						color: $color-black-5;
					}
				}
			}

		}
	}
</style>